<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
<head>
    <th:block th:include="include :: header('修改客户')" />
</head>
<body class="white-bg">
    <div class="wrapper wrapper-content animated fadeInRight ibox-content">
        <form class="form-horizontal m" id="form-customer-edit" th:object="${entityCustomer}">
            <input name="id" th:field="*{id}" type="hidden">
            <div class="form-group">    
                <label class="col-sm-3 control-label is-required">客户名称：</label>
                <div class="col-sm-8">
                    <input name="name" th:field="*{name}" class="form-control" type="text" required autocomplete="off">
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label is-required">客户地址：</label>
                <div class="col-sm-8">
                    <input name="address" th:field="*{address}" class="form-control" type="text" required autocomplete="off">
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">座机号码：</label>
                <div class="col-sm-8">
                    <input name="tel" th:field="*{tel}" class="form-control" type="text" autocomplete="off">
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label is-required">联系人：</label>
                <div class="col-sm-8">
                    <input name="contacts" th:field="*{contacts}" class="form-control" type="text" required autocomplete="off">
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label is-required">手机号码：</label>
                <div class="col-sm-8">
                    <div class="input-group">
                        <input name="phone" th:field="*{phone}" class="form-control"  type="text" required autocomplete="off">
                        <span class="input-group-addon"><i class="fa fa-mobile"></i></span>
                    </div>
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">身份证号：</label>
                <div class="col-sm-8">
                    <input name="idCard" th:field="*{idCard}" class="form-control" type="text"  autocomplete="off">
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label">有效：</label>
                <div class="col-sm-8">
                    <select class="form-control" th:field="*{valid}" name="">
                        <option value="1">有效</option>
                        <option value="0">无效</option>
                    </select>
                </div>
            </div>
        </form>
    </div>
    <th:block th:include="include :: footer" />
    <script th:inline="javascript">
        var prefix = ctx + "system/customer";
        var icon = "<i class='fa fa-times-circle'></i>";
        $("#form-customer-edit").validate({
            focusCleanup: true,
            rules: {
                name: "required",
                contacts: "required",
                address: "required",
                phone: {
                    required: true,
                    isPhone:true,
                    remote: {
                        url: "/system/customer/checkPhone",     //后台处理程序
                        type: "post",               //数据发送方式
                        dataType: "json",           //接受数据格式
                        data: {                     //要传递的数据
                            phone: function () {
                                return $("#phone").val();
                            }, id: function () {
                                return $("#id").val();
                            }
                        }
                    }
                },
                idCard: {
                    isIdentity:true,
                    remote: {
                        url: "/system/customer/checkIdCard",     //后台处理程序
                        type: "post",               //数据发送方式
                        dataType: "json",           //接受数据格式
                        data: {                     //要传递的数据
                            idCard: function () {
                                return $("#idCard").val();
                            }, id: function () {
                                return $("#id").val();
                            }
                        }
                    }
                }
            },
            messages: {
                name: icon + "请输入客户姓名",
                contacts: icon + "请输入联系人名称",
                address: icon + "请输入客户的地址",
                phone: {
                    required: icon + "请输入客户的手机号",
                    isPhone: icon + "请输入正确的手机号",
                    remote: icon + "该手机号对应的客户已经存在"
                },
                idCard: {
                    isIdentity: icon + "请输入正确的身份证号码",
                    remote: icon + "该身份证号码对应的客户已经存在"
                }
            }
        });

        function submitHandler() {
            if ($.validate.form()) {
                $.operate.save(prefix + "/edit", $('#form-customer-edit').serialize());
            }
        }
    </script>
</body>
</html>